package company.wangyi;

import java.util.Scanner;

/**
 * @author briarbear
 * @blog http://briarbear.github.io
 * @create 2018-09-08-15:55
 */
public class W12 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int t = scanner.nextInt();
            int[][] array = new int[t][2];
            for (int i = 0; i < t; i++) {
                array[i][0] = scanner.nextInt();
                array[i][1] = scanner.nextInt();
            }

            for (int i = 0; i < t; i++) {
                System.out.println("0 "+ helper(array[i][0],array[i][1]));
            }
        }
    }

    public static int helper(int a,int b){
        if (a == 0|| b == 0) return 0;
        return (b - 1) < ( a - b) ? b-1 : a - b;
    }
}
